


var page = 1;
var pagenum = 10;
var fi=1;
var url={
    list:api.recharge.list,
    // delete:api.service.delete,
    // edit:api.service.edit
}
var main=[[ //表头
    {field: 'recharge_no', title: '订单号', fixed: 'left',align: 'center',minWidth: 100}
    ,{field: 'date', title: '充值时间',minWidth: 200}
    ,{field: 'company_name', title: '公司',minWidth: 200}  
    ,{field: 'type', title: '充值类型',templet:'<div>{{d.type==1?"微信":"预充值"}}</div>'}
    ,{field:'number', title:'金额'}
    ,{field:'state', title:'充值状态',templet:'#state'}
    // ,{field:'ps', title:'备注'}
]];
var data={};
data.page=page;
data.pagenum=pagenum;
var where_json ={};

{if $Think.get.type}
where_json.type=['in','{$Think.get.type}']
{/if}

{if $Think.get.company_name}
where_json.company_name=['like','%{$Think.get.company_name}%']
{/if}

{if $Think.get.company_recharge_id}
where_json.company_recharge_id=['like','{$Think.get.company_recharge_id}']
{/if}

{if $Think.get.state}
where_json.state=['in','{$Think.get.state}'] 
{/if}

data.where_json=JSON.stringify(where_json)

ajaxrecharge(data);
function ajaxrecharge(data) {
    Load();
    //请求数据
    ajax(url.list, data, 'post').done(function (res) {
        Load(1);
        // 成功回调
        //方法级表单渲染
        console.log(res)
        if(res.code == 1){
        table.render({
            elem: '#recharge',
            cols: main,
            data: res.data,
            limit: pagenum,
            cellMinWidth: 80
        });
        if (fi == 1) {
            laypage.render({
                elem: 'page',
                count: res.count,
                layout: ['count', 'prev', 'page', 'next', 'limit', 'refresh', 'skip'],
                theme: '#1E9FFF',
                jump: function (obj, first) {
                    console.log(123)
                    console.log(res.count)
                    console.log(obj)
                    if (!first) {
                        page = obj.curr;
                        data.page = page;
                        pagenum = obj.limit;
                        data.pagenum = pagenum;
                        ajaxrecharge(data);
                    } else {

                    }
                }
            })
            fi = 2;
        }
    
    }else{
        Err(res.msg)
    }
    }).fail(function (err) {
        // 失败回调
        Load(1)
        Err('请求失败')
    });
};
